package com.globant.tab;

import com.globant.bean.PlayerBean;
import com.globant.common.MockData;
import com.globant.tab.R;

import android.app.Activity;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

public abstract class CommonTabActivity extends Activity {

	
	protected LinearLayout createHeader() {
		LayoutInflater inflater = getLayoutInflater();
		LinearLayout listHeaderView = (LinearLayout)inflater.inflate(
		            R.layout.player_info, null, true);
		listHeaderView.setFocusable(false);
		
		PlayerBean playerBean = MockData.createMockPlayer();
		TextView actualMoney = (TextView) listHeaderView.findViewById(R.id.actualMoney);
		TextView actualLevel = (TextView) listHeaderView.findViewById(R.id.actualLevel);
		TextView jobSelected = (TextView) listHeaderView.findViewById(R.id.jobSelected);
		
		TextView actualHenchmen = (TextView) listHeaderView.findViewById(R.id.actualHenchmen);
		TextView levelPoints = (TextView) listHeaderView.findViewById(R.id.levelPoints);
		ProgressBar actualLevelBar = (ProgressBar) listHeaderView.findViewById(R.id.actualLevelBar);
		
		String money = (String) getResources().getText(R.string.money);
		money = money.concat(String.valueOf(playerBean.getMoney()));
		actualMoney.setText(money);
		
		if(playerBean.getSelectedPlace() == null) {
			jobSelected.setText(getResources().getText(R.string.not_checked_in));
		} else {
			jobSelected.setText(playerBean.getSelectedPlace());
		}
		
		actualLevel.setText(String.valueOf(playerBean.getLevel()));
		
		String henchmen = String.valueOf(playerBean.getHenchmen());
		henchmen = henchmen.concat("/").concat(String.valueOf(playerBean.getMaxHenchmen()));
		actualHenchmen.setText(henchmen);
		
		String points = String.valueOf(playerBean.getExperience());
		points = points.concat("/").concat(String.valueOf(playerBean.getMaxExperience()));
		levelPoints.setText(points);
		
		double level = ((double)playerBean.getExperience()/(double)playerBean.getMaxExperience())*100;
		actualLevelBar.setProgress((int) level);
		
		return listHeaderView;
	}

}